<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>制作调价单</title>
  <link href="../../css/style.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
        <tr>
          <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
          <td valign="bottom" class="title">调价单</td>
        </tr>
      </table></td>
    </tr>
  </table>
  <form name="form1" method="post" action="" id="mod_value">

     请输入姓名:<input name="staffinfo.staname" >
    <table width="1000" size="1" class="table02">
        <tr>
        <td class="td_form01">药品编号</td>
<!--        <td class="td_form01">药品名称</td>-->
        <td class="td_form01">原单价</td>
        <td class="td_form01">调价价格</td>
        <td class="td_form01">调价日期</td>
        <td class="td_form01">操作</td>
        </tr>
      <tr>
<!--          <td class="td_form02">-->
<!--              <input type="text" size="5" name="drugname[0]">-->
<!--          </td>-->
        <td class="td_form02">
          <input type="text" size="5" name="drugid[0]">
        </td>
<!--        <td class="td_form02">-->
<!--          <input type="text" size="5" name="druginformation[0].drugname">-->
<!--        </td>-->
        <td class="td_form02">
          <input type="text" size="5" name="modprice[0].modoripri">
        </td>

        <td class="td_form02">
          <input type="text" size="5" name="modprice[0].modpri">
        </td>
        <td class="td_form02">
          <input  type="date" name="modprice[0].moddate">
        </td>
        <td class="td_form02">
          <input type="button" class="add" value="添加" onclick="add()">
          <input type="button" class="del" value="删除" onclick="del(this)">
        </td>
      </tr>
    </table>
    <br>
    <table width=95% border=0 align=center cellpadding=0 cellspacing=0 whdth='100%'>
      <tr>
        <td align="center">

          <input name=save  type=button class=buttonface value= '提交' id="stu">
          <input name=cancel  type=button class=buttonface value= '  返回  ' ></td>
      </tr>
    </table>
  </form>
</center>
</body>
</html>
<script src="../../bootstrap-3.3.7-dist/js/jquery-3.4.1.min.js"></script>
<script>
  var i=0;
  //添加一行
  function add() {

    // alert("添加")
    i++;
    var _tr ="<tr id='trs'>\n" +
            // "        <td class=\"td_form02\">\n" +
            // "          <input type=\"text\" size=\"5\" name=  \"drugname["+i+"]\">\n" +
            // "        </td>\n" +
            "        <td class=\"td_form02\">\n" +
            "          <input type=\"text\" size=\"5\" name=  \"drugid["+i+"]\">\n" +
            "        </td>\n" +
            // "        <td class=\"td_form02\">\n" +
            // "          <input type=\"text\" size=\"5\" name=  \"druginformation["+i+"].drugname\">\n" +
            // "        </td>\n" +
            "        <td class=\"td_form02\">\n" +
            "          <input type=\"text\" size=\"5\" name= \"modprice["+i+"].modoripri\">\n" +
            "        </td>\n" +
            "\n" +
            "        <td class=\"td_form02\">\n" +
            "          <input type=\"text\" size=\"5\" name= \"modprice["+i+"].modpri\">\n" +
            "        </td>\n" +
            "        <td class=\"td_form02\">\n" +
            "          <input  type=\"date\" name= \"modprice["+i+"].moddate\">\n" +
            "        </td>\n" +
            "        <td class=\"td_form02\">\n" +
            "          <input type=\"button\" class=\"add\" value=\"添加\" onclick='add()'>\n" +
            "          <input type=\"button\" class=\"del\" value=\"删除\" onclick=\"del(this)\">\n" +
            "        </td>\n" +
            "      </tr>"
    $(".table02").append(_tr);


    console.log(i)
  }
  //删除一行
  function del($this) {
    i--;
    console.log(i)
    // alert("删除")
    $($this).parent().parent().remove();
  }

//获取页面的值
$("#stu").on("click",function () {

    $.ajax({
                url:"/feign/modprices/insert",
                data:$("#mod_value").serialize(),
                type:"post",
                dataType:"json",
               headers: {
                 Accept: "application/json; charset=utf-8",
                 Authorization: location.href.split("=")[1]
                        },
                dataType: "text",
                success:function (masg) {
                  alert(masg)
                  if (masg=="添加成功") {
                    alert("添加成功")
                  }else {
                    alert("添加失败")
                  }
      },

     });

    })

</script>